package com.letoken.platform.repo.ecommerce.dao;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.letoken.platform.pub.req.PageData;
import com.letoken.platform.pub.res.ApiResponse;
import com.letoken.platform.repo.app.req.mall.CollectShopsReq;
import com.letoken.platform.repo.app.res.mall.MallCollectShopsRes;
import com.letoken.platform.repo.ecommerce.dto.UserFollowListReq;
import com.letoken.platform.repo.ecommerce.po.EcommerceProductCollect;
import com.letoken.platform.repo.ecommerce.po.EcommerceShopFollow;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.letoken.platform.repo.ecommerce.vo.UserFollowListRes;
import com.letoken.platform.repo.mall.po.AppMallCollect;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * <p>
 * 店铺关注表 Mapper 接口
 * </p>
 *
 * @author author
 * @since 2023-11-16
 */
public interface EcommerceShopFollowMapper extends BaseMapper<EcommerceShopFollow> {

    Page<UserFollowListRes> shops(@Param("page") Page<UserFollowListRes> page , @Param("req") UserFollowListReq req);

    @Select("select 1 from app_mall_info where id = #{mallId} and state = 1 and publish_state = 0 limit 1")
    Integer mallIsExits(@Param("mallId") Integer mallId);


    @Select("select id,state from ecommerce_shop_follow where mall_id  = #{mallId} and user_id = #{userId} limit 1")
    EcommerceShopFollow followIsExits(@Param("mallId") Integer mallId, @Param("userId") Integer userId);


    void updateBatchById(@Param("list") List<EcommerceShopFollow> list);


    @Update("update ecommerce_shop_follow set state = 1 where mall_id = #{mallId} and user_id = #{userId} ")
    int updateByMallId(@Param("mallId") Integer mallId ,@Param("userId") Integer userId);



    @Select("select count(1) from ecommerce_shop_follow where user_id = #{userId} and state = 0 ")
    Integer followNum(@Param("userId") Integer userId);

}
